Skip to content

Conversation

@ethanndickson
Copy link
Member

Problem

The Comprehensive demo story had flaky snapshots because projects in the sidebar did not render in a consistent order when projectOrder was empty (initial state in Storybook).

Root cause: sortProjectsByOrder() returned projects in Map insertion order when order was empty. Map insertion order depends on how data is constructed, making it non-deterministic across test runs.

Solution

When no custom order is set, sort projects lexically instead of using insertion order. This guarantees a stable, deterministic render order.

Impact

  • Storybook: Projects render in consistent alphabetical order when no custom ordering is saved
  • Production: New users see projects sorted alphabetically until they drag-reorder
  • Existing users: No change—their saved projectOrder is non-empty, so existing sort logic applies

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

sortProjectsByOrder() returned projects in Map insertion order when
projectOrder was empty. This caused flaky snapshots in the Comprehensive
demo story because insertion order varies with mock setup.

Now sorts lexically when no custom order is set, ensuring consistent
render order regardless of data construction.

---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking: `high`_
@ethanndickson ethanndickson added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit 1adeaec Dec 18, 2025
20 checks passed
@ethanndickson ethanndickson deleted the sidebar-629s branch December 18, 2025 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant